<template>
  <div class="container">
    <div>
      <el-row :gutter="12">
        <el-col :span="6">
          <el-form ref="form" :model="form">
            <el-form-item label="选择日期：">
              <el-date-picker
                v-model="form.valueDay"
                :type="form.typeDatePicker"
                :value-format="form.formatDatePicker"
                placeholder="选择日期"
                style="width: 180px"
              ></el-date-picker>
            </el-form-item>
          </el-form>
        </el-col>
        <el-col :span="6">
          <el-form ref="form" :model="form" style="float: left">
            <el-button size="mini" type="primary" @click="getDataReality"
              >查 询</el-button
            >
            <el-button size="mini" type="success" @click="exportExcel"
              >导 出</el-button
            >
          </el-form>
        </el-col>
      </el-row>
    </div>
    <el-table
    v-loading="loading"
      :data="
        tableData.slice((currentPage - 1) * pageSize, currentPage * pageSize)
      "
    >
          <el-table-column
            prop="ID"
            label="序号"
            align="center"
          ></el-table-column>
      <el-table-column
        prop="报警车辆"
        label="报警车辆"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="报警类型"
        label="报警类型"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="报警地点"
        label="报警地点"
        align="center"
      ></el-table-column>
      <!-- <el-table-column
        prop="扣分"
        label="扣分"
        align="center"
      ></el-table-column> -->
      <el-table-column
        prop="报警时间"
        label="报警时间"
        align="center"
      ></el-table-column>
        <el-table-column label="车前照片" width="150px" align="center">
              <template slot-scope="scope">
                <el-image
                  style="width: 45px; height: 45px; margin-top: 5px;"
                  :src="scope.row.qsrc"
                  @click="bigImage(scope.row)"
                >
                <div slot="error" class="image-slot" style="margin-top: 10px">
                  <i class="el-icon-picture-outline"></i>
                 </div>
                </el-image>
              </template>
        </el-table-column>
        <el-table-column label="车后照片" width="150px" align="center">
              <template slot-scope="scope">
                <el-image
                  style="width: 45px; height: 45px; margin-top: 5px;"
                  :src="scope.row.hsrc"
                  @click="bigImage2(scope.row)"
                >
                <div slot="error" class="image-slot" style="margin-top: 10px">
                  <i class="el-icon-picture-outline"></i>
                 </div>
                </el-image>
              </template>
        </el-table-column>
      <!-- <el-table-column label="操作" width="150">
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="handleEdit(scope.$index, scope.row)"
            >明细</el-button
          >
          <el-button
            type="text"
            @click="handleShowMap(scope.$index, scope.row)"
            >地图</el-button
          >
        </template>
      </el-table-column> -->
    </el-table>
    <div class="pagination">
      <el-pagination
        background
        layout="total, sizes, prev, pager, next, jumper"
        :current-page="currentPage"
        :page-size="pageSize"
        :total="tableData.length"
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
      ></el-pagination>
    </div>

    <!-- 图片放大 -->
    <el-dialog
      title="图片展示"
      :visible.sync="showBigDialogVisible"
      width="30%"
      :before-close="handleClose"
    >
      <el-image
        style="width: 100%; height: 100%"
        :src="srcBig"
      ></el-image>
    </el-dialog>
  </div>
</template>
<script>
import '@/assets/css/common.css'
import { formatDate } from '@/common/js/date.js'
import export2Excel from '@/utils/exportExcel/index.js'
export default {
  data () {
    return {
      loading: false,
      currentPage: 1, // 初始页
      pageSize: 10, //    每页的数据
      form: {
        radioData: '日',
        valueDay: '',
        valueDaySelect: '',
        valueMonth: '',
        valuePointID: '',
        valueType: '',
        typeDatePicker: 'date',
        formatDatePicker: 'yyyy-MM-dd',
        queryType: 1,
        queryTypeList: [{
          value: 1,
          label: '按日期查询'
        }, {
          value: 2,
          label: '按月份查询'
        }]
      },
      selectPointData: [],
      tableData: [],
      dialogDetail2Title: '',
      dialogDetail2Show: false,
      dialogDetail2Data: [],
      dialogDetail3Title: '',
      dialogDetail3Show: false,
      dialogDetail3Data: [],
      dialogDetail4Title: '',
      dialogDetail4Show: false,
      dialogDetail4Data: [],
      dialogDetail5Title: '',
      dialogDetail5Show: false,
      dialogDetail5Data: [],
      showBigDialogVisible: false
    }
  },
  created () {
    this.form.valueDay = formatDate(new Date(new Date() - 3600 * 1000 * 24), 'yyyy-MM-dd')
    this.form.valueMonth = formatDate(new Date(), 'yyyy-MM')
    this.getDataPlan()
  },
  methods: {
    // handleShowMap (index, row) {
    //   this.$router.push({ name: 'RouteStatisticsMap', params: { data: row } })
    // },
    // async getDataReality () {
    //   this.loading = true;
    //   var url = 'RubbishVehicle/GetRubbishHistoryVehicleCCApi?TYPE=0&WORKDATE=' + this.form.valueDay + '&CLIENT_NO=' + localStorage.getItem('CLIENT_NO')
    //   const { data } = await this.$Http.get(url)
    //   var vid = data[0].车辆编号;
    //   var arrayPointInfoOfCar = [];
    //   var arrayDataReality = [];
    //   data.forEach(element => {
    //     if (vid != element.车辆编号) {
    //       arrayDataReality.push({ 'VID': arrayPointInfoOfCar[0].车辆编号, 'NAME': arrayPointInfoOfCar[0].车辆名称, 'DATAREAL': arrayPointInfoOfCar, 'DATACOUNTREAL': arrayPointInfoOfCar.length })
    //       vid = element.车辆编号;
    //       arrayPointInfoOfCar = [];
    //     }
    //     arrayPointInfoOfCar.push(element);
    //   });
    //   this.getDataPlan(arrayDataReality)
    // },
    // 放大图片
    bigImage (row) {
      this.srcBig = row.qsrc
      this.showBigDialogVisible = true
    },
    // 放大图片
    bigImage2 (row) {
      this.srcBig = row.hsrc
      this.showBigDialogVisible = true
    },
    async getDataPlan () {
      this.tableData = [{
        ID: '14',
        报警车辆: '津C52582',
        报警类型: '保洁不达标',
        报警地点: '天津市津南区嘉园道',
        扣分: '-5',
        报警时间: '2022-08-31 05:00',
        qsrc: 'http://picture-adv-hb2.oss-cn-beijing.aliyuncs.com/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20220830165850.jpg',
        hsrc: 'http://picture-adv-hb2.oss-cn-beijing.aliyuncs.com/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20220830165847.jpg'
      }, {
        ID: '15',
        报警车辆: '津C50890',
        报警类型: '保洁不达标',
        报警地点: '天津市滨海新区世纪大道',
        扣分: '-5',
        报警时间: '2022-08-31 15:23',
        qsrc: 'http://picture-adv-hb2.oss-cn-beijing.aliyuncs.com/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20220831092811.png',
        hsrc: 'http://picture-adv-hb2.oss-cn-beijing.aliyuncs.com/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20220831092802.png'
      }
      ]
    },
    // 导出Excel
    exportExcel () {
      const excelName = '收运点位分析'
      var tHeader = ['车辆名称', '计划收运点位数', '实际收运点位数', '作业率']
      var filterVal = ['NAME', 'DATACOUNTPLAN', 'DATACOUNTREAL', 'WORKRATE']
      export2Excel(tHeader, filterVal, this.tableData, excelName)
    },
    handleEdit (index, row) {
      this.dialogDetail3Title = '垃圾点明细'
      this.dialogDetail3Data = row.DATAREAL
      console.log(row.DATAREAL)
      this.dialogDetail3Show = true
    },
    // 分页导航
    handlePageChange (currentPage) {
      this.currentPage = currentPage
      // console.log(this.currentPage)
      // this.$set(this.query, 'pageIndex', val);
      // this.getData();
    },
    handleSizeChange (size) {
      this.pageSize = size
      console.log(this.pageSize)
    }
  }
}
</script>
<style>
.content {
  overflow-y: scroll;
}
.el-col-6 {
  min-width: 400px;
  min-height: 50px;
}
.el-table th {
  height: 40px;
}
/* 弹出框 */
.el-dialog {
  background: #ccd8e7;
  padding: 0px 10px 10px;
}
.el-dialog__title {
  color: #15428b;
  font-size: 16px;
  font-weight: 600;
}
.el-dialog__body {
  background: #dfe8f6;
  border: 1px solid #99bbe8;
}
.el-dialog__footer {
  padding: 10px 0px;
}
</style>
